proc isshipgoner
    var workrecord : ship
    var numhits : int
    shipkilluser := 0
    shipkillcomp := 0
    for i : 1 .. 5
	workrecord := compships (i)
	numhits := 0
	if workrecord.mode = 1 then
	    for a : workrecord.startx .. workrecord.endx
		if comploc (a, workrecord.starty) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.endx - workrecord.startx) + 1 then
		    putout ("You destroyed ship " + intstr (i) + "!")
		    shipkilluser += 1
		end if
	    end for
	elsif workrecord.mode = 2 then
	    for decreasing a : workrecord.startx .. workrecord.endx
		if comploc (a, workrecord.starty) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.startx - workrecord.endx) + 1 then
		    putout ("You destroyed ship " + intstr (i) + "!")
		    shipkilluser += 1
		end if
	    end for
	elsif workrecord.mode = 3 then
	    for a : workrecord.starty .. workrecord.endy
		if comploc (workrecord.startx, a) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.endy - workrecord.starty) + 1 then
		    putout ("You destroyed ship " + intstr (i) + "!")
		    shipkilluser += 1
		end if
	    end for
	elsif workrecord.mode = 4 then
	    for decreasing a : workrecord.starty .. workrecord.endy
		if comploc (workrecord.startx, a) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.starty - workrecord.endy) + 1 then
		    putout ("You destroyed ship " + intstr (i) + "!")
		    shipkilluser += 1
		end if
	    end for
	end if
    end for

    for i : 1 .. 5
	workrecord := userships (i)
	numhits := 0
	if workrecord.mode = 1 then
	    for a : workrecord.startx .. workrecord.endx
		if userloc (a, workrecord.starty) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.endx - workrecord.startx) + 1 then
		    putout ("Comp destroyed ship " + intstr (i) + "!")
		    shipkillcomp += 1
		end if
	    end for
	elsif workrecord.mode = 2 then
	    for decreasing a : workrecord.startx .. workrecord.endx
		if userloc (a, workrecord.starty) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.startx - workrecord.endx) + 1 then
		    putout ("Comp destroyed ship " + intstr (i) + "!")
		    shipkillcomp += 1
		end if
	    end for
	elsif workrecord.mode = 3 then
	    for a : workrecord.starty .. workrecord.endy
		if userloc (workrecord.startx, a) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.endy - workrecord.starty) + 1 then
		    putout ("Comp destroyed ship " + intstr (i) + "!")
		    shipkillcomp += 1
		end if
	    end for
	elsif workrecord.mode = 4 then
	    for decreasing a : workrecord.starty .. workrecord.endy
		if userloc (workrecord.startx, a) = 2 then
		    numhits += 1
		end if
		if numhits = (workrecord.starty - workrecord.endy) + 1 then
		    putout ("Comp destroyed ship " + intstr (i) + "!")
		    shipkillcomp += 1
		end if
	    end for
	end if
    end for
end isshipgoner
